#李聪 2022/3/7
#构建网络
#使用ResNet做特征提取
import torch
import torchvision

resnet = torchvision.models.resnet152(pretrained=True)
#print(resnet)
resnet.fc=torch.nn.Sequential(
    torch.nn.Linear(in_features=2048,out_features=1023,bias=True),
    torch.nn.ReLU(inplace=True),
    torch.nn.Dropout(p=0.2),
    torch.nn.Linear(in_features=1023,out_features=512,bias=True),
    torch.nn.ReLU(inplace=True),
    torch.nn.Dropout(p=0.2),
    torch.nn.Linear(in_features=512,out_features=128,bias=True)
)
# resnet.add_module("last_Linear",torch.nn.Sequential(
#     torch.nn.Linear(in_features=2048,out_features=1023,bias=True)
#     torch.nn.ReLU(inplace=True),
#     torch.nn.Dropout(p=0.2),
#     torch.nn.Linear(in_features=1023,out_features=512,bias=True),
#     torch.nn.ReLU(inplace=True),
#     torch.nn.Dropout(p=0.2),
#     torch.nn.Linear(in_features=512,out_features=128,bias=True)
# ))


print(resnet)


inputs=torch.ones((64,3,224,224))
print(inputs)
output=resnet(inputs)
print(output)
print(output.shape)